package com.caption.core.model.entity;

import com.caption.core.model.enums.BaseResultEnum;
import com.caption.core.model.enums.ResultEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * 返回的数据封装对象
 */
@Data
public class BaseData<T> implements Serializable {

    private static final long serialVersionUID = 984170620748996L;

    private Integer code = BaseResultEnum.SUCCESS.getCode();

    private String message = BaseResultEnum.SUCCESS.getDesc();

    private T data;

    public BaseData() {
    }

    public BaseData(int resultCode) {
        this.code = resultCode;
        this.message = "无说明";
    }

    public BaseData(int resultCode, String errMsg) {
        this.code = resultCode;
        this.message = errMsg;
    }

    public BaseData(ResultEnum<Integer> resultCode) {
        this.code = resultCode.getCode();
        this.message = resultCode.getDesc();
    }

    public BaseData(ResultEnum<Integer> resultCode, String errMsg) {
        this.code = resultCode.getCode();
        this.message = errMsg;
    }

    public BaseData(T data) {
        this.data = data;
    }
}
